package com.yang.springcloud.pojo;

import com.sun.org.apache.bcel.internal.generic.FADD;

/**
 * @author shiwen
 * @date 2020/10/12
 */
public class MainApp {

    // 数值反转 1234
    public static int reverse(int x) {
        long result = 0;
        while (x != 0) {
            // 每次进来取出最后一位
            int lastNum = x % 10;
            result = result * 10 + lastNum;
            x = x / 10;
        }
        return result == (int) result ? (int) result : 0;
    }

    public static boolean isPalindrome(int x) {
        if (x < 0) {
            return false;
        }
        int inputNum = x;
        int result = 0;
        while (x != 0) {
            int lastNum = x % 10;
            result = result * 10 + lastNum;
            x = x / 10;
        }
        return result == inputNum ? true : false;
    }

    public static void main(String[] args) {
        //System.out.println(reverse(123456789));
        System.out.println(isPalindrome(-121));
    }

}
